package com.chenfan.mcn.enums;

import com.chenfan.common.extension.dict.DictTranslator;

import java.util.Objects;

/**
 * 归档状态枚举
 *
 * @Author liuyang
 * @Date 2021/9/29
 * @Time 11:23
 * @Version V1.0
 **/
public enum ArchivingStatusEnum implements DictTranslator<Integer, String> {

    /**
     * 归档状态枚举
     */
    TO_BE_SEALED(0, "待盖章"),

    TO_BE_FILED(1, "待归档"),

    ARCHIVED(2, "已归档");

    private final int code;
    private final String statusName;

    ArchivingStatusEnum(int code, String statusName) {
        this.code = code;
        this.statusName = statusName;
    }

    public int code() {
        return this.code;
    }

    public static String getStatusName(int code) {
        for (ArchivingStatusEnum status : ArchivingStatusEnum.values()) {
            if (status.code == code) {
                return status.statusName;
            }
        }
        return null;
    }

    @Override
    public String translate(Integer code) {
        return Objects.nonNull(code) ? getStatusName(code.intValue()) : null;
    }
}
